package pkgscanner.util;


/**
 * @author 星环
 * @date 2023/3/9 19:18:05
 * @description
 */
public class StringUtils {
    public static String packageNameToRealPath(String pName,boolean leftSlash){
        String name;
        if (leftSlash){
            name = pName.replaceAll("\\.","/");
        }else {
            name = pName.replaceAll("\\.","\\");
        }
        String rootPath = StringUtils.class.getClassLoader().getResource("").getPath();
        return rootPath + name;
    }

    public static String realPathToPackageName(String path){
        String classRootPath = StringUtils.class.getClassLoader().getResource("").getPath();
        return path.substring(classRootPath.length() - 1);
    }
    public static String realPathToClassFullName(String path){
        String classRootPath = StringUtils.class.getClassLoader().getResource("").getPath();
        return path.substring(classRootPath.length() - 1, path.length() - 6).replaceAll("\\\\",".");
    }
}

